import { NgModule } from '@angular/core';
import { CommonModule, registerLocaleData } from '@angular/common';

import { BrowserModule } from '@angular/platform-browser';
import { HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { AppRoutingModule } from '../app-routing.module';

import { CookieService } from 'ngx-cookie-service';

import en from '@angular/common/locales/en';

import { NZ_ICONS } from 'ng-zorro-antd/icon';
import { NZ_I18N, en_US } from 'ng-zorro-antd/i18n';
import { IconDefinition } from '@ant-design/icons-angular';
import * as AllIcons from '@ant-design/icons-angular/icons';

import { Oauth2 } from '../classes/oauth2';

// Service
import { LoginGuard } from '../services/login.guard';

// Interceptor
import { DefaultInterceptor } from '../core/interceptors/default.interceptor';
import { ShareModule } from './share/share.module';
import { AppStoreModule } from './share/modal-box/store';
import { ServicesModule } from '../services/services.module';
import { PageModule } from './page.module';

/**
 * <<< Components
 */

registerLocaleData(en);

const antDesignIcons = AllIcons as {
  [key: string]: IconDefinition;
};
const icons: IconDefinition[] = Object.keys(antDesignIcons).map(key => antDesignIcons[key]);

@NgModule({
  declarations: [
    // LoginComponent,
    // EditorComponent,
    // EditorMdDirective,
    // SecurityComponent
  ],
  imports: [
    CommonModule,
    BrowserModule,
    FormsModule, ReactiveFormsModule,
    AppRoutingModule,
    HttpClientModule,
    BrowserAnimationsModule,

    ShareModule,
    PageModule,
    AppStoreModule,
    ServicesModule
  ],
  exports: [
    AppRoutingModule,
    BrowserModule,
    ShareModule
  ],
  providers: [
    Oauth2,
    {
      provide: NZ_I18N, useValue: en_US
    },
    {
      provide: NZ_ICONS, useValue: icons
    },
    LoginGuard,
    {
      provide: HTTP_INTERCEPTORS, useClass: DefaultInterceptor, multi: true
    },
    CookieService
  ],
})
export class CoreModule { }
